package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-05-20
 * Time: 16:13
 */
public class computer {
    public void open(){
            System.out.println("开机");
        }
        public void close(){
            System.out.println("关机");
    }
    public void useUsbDevice(USB usb){
        usb.openDevice();
        if(usb instanceof mouse){
            mouse mouse = (mouse)usb;//向下转型
            mouse.click();
        }else{
            keyBoard keyboard = (keyBoard) usb;//向下转型
            keyboard.typing();
        }
        usb.closeDevice();
    }
}
